<?php


/**
 * Base class that represents a query for the 'lp_vv_Stanowiska' table.
 *
 *
 *
 * @method LpPositionsBaseQuery orderById($order = Criteria::ASC) Order by the LpStanowisko column
 * @method LpPositionsBaseQuery orderByType($order = Criteria::ASC) Order by the StanowiskoRodzaj column
 * @method LpPositionsBaseQuery orderByNamePl($order = Criteria::ASC) Order by the Nazwa column
 * @method LpPositionsBaseQuery orderByNameEn($order = Criteria::ASC) Order by the NazwaObca column
 *
 * @method LpPositionsBaseQuery groupById() Group by the LpStanowisko column
 * @method LpPositionsBaseQuery groupByType() Group by the StanowiskoRodzaj column
 * @method LpPositionsBaseQuery groupByNamePl() Group by the Nazwa column
 * @method LpPositionsBaseQuery groupByNameEn() Group by the NazwaObca column
 *
 * @method LpPositionsBaseQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method LpPositionsBaseQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method LpPositionsBaseQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method LpPositionsBase findOne(PropelPDO $con = null) Return the first LpPositionsBase matching the query
 * @method LpPositionsBase findOneOrCreate(PropelPDO $con = null) Return the first LpPositionsBase matching the query, or a new LpPositionsBase object populated from the query conditions when no match is found
 *
 * @method LpPositionsBase findOneById(string $LpStanowisko) Return the first LpPositionsBase filtered by the LpStanowisko column
 * @method LpPositionsBase findOneByType(string $StanowiskoRodzaj) Return the first LpPositionsBase filtered by the StanowiskoRodzaj column
 * @method LpPositionsBase findOneByNamePl(string $Nazwa) Return the first LpPositionsBase filtered by the Nazwa column
 * @method LpPositionsBase findOneByNameEn(string $NazwaObca) Return the first LpPositionsBase filtered by the NazwaObca column
 *
 * @method array findById(string $LpStanowisko) Return LpPositionsBase objects filtered by the LpStanowisko column
 * @method array findByType(string $StanowiskoRodzaj) Return LpPositionsBase objects filtered by the StanowiskoRodzaj column
 * @method array findByNamePl(string $Nazwa) Return LpPositionsBase objects filtered by the Nazwa column
 * @method array findByNameEn(string $NazwaObca) Return LpPositionsBase objects filtered by the NazwaObca column
 *
 * @package    propel.generator.lp.om
 */
abstract class LpBasePositionsBaseQuery extends ModelCriteria
{
    /**
     * Initializes internal state of LpBasePositionsBaseQuery object.
     *
     * @param     string $dbName The dabase name
     * @param     string $modelName The phpName of a model, e.g. 'Book'
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     */
    public function __construct($dbName = 'vw_lp', $modelName = 'LpPositionsBase', $modelAlias = null)
    {
        parent::__construct($dbName, $modelName, $modelAlias);
    }

    /**
     * Returns a new LpPositionsBaseQuery object.
     *
     * @param     string $modelAlias The alias of a model in the query
     * @param     LpPositionsBaseQuery|Criteria $criteria Optional Criteria to build the query from
     *
     * @return LpPositionsBaseQuery
     */
    public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof LpPositionsBaseQuery) {
            return $criteria;
        }
        $query = new LpPositionsBaseQuery();
        if (null !== $modelAlias) {
            $query->setModelAlias($modelAlias);
        }
        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }

    /**
     * Find object by primary key.
     * Propel uses the instance pool to skip the database if the object exists.
     * Go fast if the query is untouched.
     *
     * <code>
     * $obj  = $c->findPk(12, $con);
     * </code>
     *
     * @param mixed $key Primary key to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return   LpPositionsBase|LpPositionsBase[]|mixed the result, formatted by the current formatter
     */
    public function findPk($key, $con = null)
    {
        if ($key === null) {
            return null;
        }
        if ((null !== ($obj = LpPositionsBasePeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
            // the object is alredy in the instance pool
            return $obj;
        }
        if ($con === null) {
            $con = Propel::getConnection(LpPositionsBasePeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
         || $this->map || $this->having || $this->joins) {
            return $this->findPkComplex($key, $con);
        } else {
            return $this->findPkSimple($key, $con);
        }
    }

    /**
     * Find object by primary key using raw SQL to go fast.
     * Bypass doSelect() and the object formatter by using generated code.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return   LpPositionsBase A model object, or null if the key is not found
     * @throws   PropelException
     */
    protected function findPkSimple($key, $con)
    {
        $sql = 'SELECT LPSTANOWISKO, STANOWISKORODZAJ, NAZWA, NAZWAOBCA FROM lp_vv_Stanowiska WHERE LPSTANOWISKO = :p0';
        try {
            $stmt = $con->prepare($sql);
            $stmt->bindValue(':p0', $key, PDO::PARAM_STR);
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
        }
        $obj = null;
        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $obj = new LpPositionsBase();
            $obj->hydrate($row);
            LpPositionsBasePeer::addInstanceToPool($obj, (string) $key);
        }
        $stmt->closeCursor();

        return $obj;
    }

    /**
     * Find object by primary key.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return LpPositionsBase|LpPositionsBase[]|mixed the result, formatted by the current formatter
     */
    protected function findPkComplex($key, $con)
    {
        // As the query uses a PK condition, no limit(1) is necessary.
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKey($key)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    }

    /**
     * Find objects by primary key
     * <code>
     * $objs = $c->findPks(array(12, 56, 832), $con);
     * </code>
     * @param     array $keys Primary keys to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return PropelObjectCollection|LpPositionsBase[]|mixed the list of results, formatted by the current formatter
     */
    public function findPks($keys, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKeys($keys)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->format($stmt);
    }

    /**
     * Filter the query by primary key
     *
     * @param     mixed $key Primary key to use for the query
     *
     * @return LpPositionsBaseQuery The current query, for fluid interface
     */
    public function filterByPrimaryKey($key)
    {

        return $this->addUsingAlias(LpPositionsBasePeer::LPSTANOWISKO, $key, Criteria::EQUAL);
    }

    /**
     * Filter the query by a list of primary keys
     *
     * @param     array $keys The list of primary key to use for the query
     *
     * @return LpPositionsBaseQuery The current query, for fluid interface
     */
    public function filterByPrimaryKeys($keys)
    {

        return $this->addUsingAlias(LpPositionsBasePeer::LPSTANOWISKO, $keys, Criteria::IN);
    }

    /**
     * Filter the query on the LpStanowisko column
     *
     * Example usage:
     * <code>
     * $query->filterById('fooValue');   // WHERE LpStanowisko = 'fooValue'
     * $query->filterById('%fooValue%'); // WHERE LpStanowisko LIKE '%fooValue%'
     * </code>
     *
     * @param     string $id The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return LpPositionsBaseQuery The current query, for fluid interface
     */
    public function filterById($id = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($id)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $id)) {
                $id = str_replace('*', '%', $id);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(LpPositionsBasePeer::LPSTANOWISKO, $id, $comparison);
    }

    /**
     * Filter the query on the StanowiskoRodzaj column
     *
     * Example usage:
     * <code>
     * $query->filterByType('fooValue');   // WHERE StanowiskoRodzaj = 'fooValue'
     * $query->filterByType('%fooValue%'); // WHERE StanowiskoRodzaj LIKE '%fooValue%'
     * </code>
     *
     * @param     string $type The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return LpPositionsBaseQuery The current query, for fluid interface
     */
    public function filterByType($type = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($type)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $type)) {
                $type = str_replace('*', '%', $type);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(LpPositionsBasePeer::STANOWISKORODZAJ, $type, $comparison);
    }

    /**
     * Filter the query on the Nazwa column
     *
     * Example usage:
     * <code>
     * $query->filterByNamePl('fooValue');   // WHERE Nazwa = 'fooValue'
     * $query->filterByNamePl('%fooValue%'); // WHERE Nazwa LIKE '%fooValue%'
     * </code>
     *
     * @param     string $namePl The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return LpPositionsBaseQuery The current query, for fluid interface
     */
    public function filterByNamePl($namePl = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($namePl)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $namePl)) {
                $namePl = str_replace('*', '%', $namePl);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(LpPositionsBasePeer::NAZWA, $namePl, $comparison);
    }

    /**
     * Filter the query on the NazwaObca column
     *
     * Example usage:
     * <code>
     * $query->filterByNameEn('fooValue');   // WHERE NazwaObca = 'fooValue'
     * $query->filterByNameEn('%fooValue%'); // WHERE NazwaObca LIKE '%fooValue%'
     * </code>
     *
     * @param     string $nameEn The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return LpPositionsBaseQuery The current query, for fluid interface
     */
    public function filterByNameEn($nameEn = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($nameEn)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $nameEn)) {
                $nameEn = str_replace('*', '%', $nameEn);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(LpPositionsBasePeer::NAZWAOBCA, $nameEn, $comparison);
    }

    /**
     * Exclude object from result
     *
     * @param   LpPositionsBase $positionsBase Object to remove from the list of results
     *
     * @return LpPositionsBaseQuery The current query, for fluid interface
     */
    public function prune($positionsBase = null)
    {
        if ($positionsBase) {
            $this->addUsingAlias(LpPositionsBasePeer::LPSTANOWISKO, $positionsBase->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }

}
